package org.web3j.crypto.seele;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.web3j.crypto.Credentials;
import org.web3j.crypto.Keys;

import java.math.BigInteger;

public class TransactionUtils {

    public static String toJson(Transaction tx) {
        Gson gson= new GsonBuilder().disableHtmlEscaping().create();
        return gson.toJson(tx);
    }


    public static String test() {
        Credentials credentials = SampleKeys.CREDENTIALS;

        int shard = Keys.shard(credentials.getAddress());

        System.out.print(SampleKeys.TAG+shard);

        String to = "0x0000000000000000000000000000000000000000";

        BigInteger gasPriceInt = BigInteger.valueOf(1);
        BigInteger gasLimitInt = BigInteger.valueOf(3000000);
        BigInteger valueInt = BigInteger.valueOf(0);
        BigInteger nonceInt = BigInteger.valueOf(0);

        String data="";

        RawTransaction rawTx = RawTransaction.createTransaction(nonceInt, gasPriceInt, gasLimitInt, to, valueInt,data);

        Transaction tx = TransactionEncoder.signSeeleMessage(rawTx, credentials);

        return toJson(tx);

    }

}
